﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IndyMosaic.Models.Web;
using IndyMosaic.Core.ActionFilters;

namespace IndyMosaic.Org.Site.Controllers
{
    public class PrayerRequestController : Controller
    {
        //
        // GET: /PrayerRequests/
        [HttpGet]
        public ActionResult Index()
        {
            return View(new PrayerRequest());
        }

        [CaptchaValidator]
        [HttpPost]
        public ActionResult Index(PrayerRequest prayerRequest, RecaptchaResponse recaptchaResponse)
        {
            if (recaptchaResponse.IsValid)
            {
                prayerRequest.Send();
                return View("RequestSent");
            }
            else
            {
                ViewData["errorMessage"] = recaptchaResponse.ErrorMessage;
                return View(prayerRequest);
            }
        }

    }
}
